import axiosServer from "@/utils/request";

/**
 * Add advertisement
 * @param pictureBase Image
 * @param name Title
 * @param brief Introduction
 * @param content Content - fill in the link
 * @param isVIP 0 (false) and 1 (true) whether it is VIP
 * @param formData
 * @returns {*}
 */
export const addBanner = (formData) => {
    return axiosServer({
        method: "post",
        url: "/advertisement/add",
        data: formData
    });
};

/**
 * Delete advertisement
 * @param id
 * @returns {*}
 */
export const deleteBanner = (id) => {
    return axiosServer({
        method: "post",
        url: "/advertisement/delete/" + id,
    });
};

/**
 * Query advertisements with pagination (backend)
 * @param page
 * @param limit
 * @returns {*}
 */
export const listDataBanner = (page, limit) => {
    return axiosServer({
        method: "get",
        url: "/advertisement/listData",
        params: { page, limit }
    });
};

/**
 * Publish or unpublish advertisement
 * @param id
 * @param upper // true or false
 * @returns {*}
 */
export const updateUpperBanner = (id, upper) => {
    return axiosServer({
        method: "post",
        url: "/advertisement/updateUpper",
        params: { id, upper }
    });
};

/**
 * Modify VIP status of advertisement (backend)
 * @param id
 * @param isVIP
 * @returns {*}
 */
export const updateVIPBanner = (id, isVIP) => {
    return axiosServer({
        method: "post",
        url: "/advertisement/updateVIP",
        params: { id, isVIP }
    });
};

/**
 * Delete advertisement (backend)
 * @param id
 * @param isVIP
 * @returns {*}
 */
export const deleteVIPBanner = (id) => {
    return axiosServer({
        method: "delete",
        url: "/advertisement/delete/" + id,
    });
};